/**
 *@module Region
 *@desc 企业信息-区域
 *@author LiHongKun
 *@date 2018-08-10 11:36:58
 */
Ext.define('js.ranInsOfProQui.ranInsOfProQuiAAddPage', {
    extend: 'Ext.form.Panel',
    requires: ['js.Util', 'js.ctrl.Common'],
    controller: 'Common',
    config: {
        bodyPadding: '0 20 0 20',
        layout: {
            type: 'vbox',
            align: 'stretch'
        }
    },
    hidenField: {
        region_id: undefined
    },
    defaults: {
        labelWidth:140,
        flex:1,
        allowBlank: false
    },
    url: 'qualityCheckRoutes',
    initComponent: function () {
        Ext.QuickTips.init();
        Ext.form.Field.prototype.msgTarget = 'under';
        let basicInformationList={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'datefield',
                editable:false,
                name: 'check_date',
                id: 'check_date',
                allowBlank: false,
                value:this.check_date,
                msgTarget : 'qtip',
                width: '50%',
                margin:'20 0 10 0',
                labelSeparator: '',
                fieldLabel: '抽查日期:'
            },{
                xtype: 'textfield',
                name: 'user_ids',
                id: 'userIdsObject_person',
                allowBlank: false,
                value:this.user_ids,
                hidden:true,
                msgTarget : 'qtip',
                margin:'5 0 10 0',
                labelSeparator: '',
                fieldLabel: '<span style="margin-left:50px; ">抽查人员id</span>:'
            },{
                xtype: 'textfield',
                name: 'user_name',
                id: 'user_nameObject_person',
                value:this.user_name,
                allowBlank: false,
                msgTarget : 'qtip',
                width: '50%',
                margin:'20 0 10 0',
                labelSeparator: '',
                fieldLabel: '<span style="margin-left:30px; ">抽查人员</span>:',
                listeners: {
                    render: function(p) {
                        p.getEl().on('click', function(p){
                            let a = Ext.getCmp('BasGraphAddWindow');
                            if(a) a.remove(a);
                            let formPanel = Ext.create('js.basicInformation.BasGraphAddWindow',{
                                idA:'userIdsObject_person',
                                nameA:'user_nameObject_person',
                                actionType:'duoccry'
                            });
                            let win = util.window(formPanel, {title:'添加抽查人员' ,width:'600',height:'600'});
                            win.show();
                        });
                    }}
            }
            ]

        }
        let basicInformationListA={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'combobox',
                width: '100%',
                name: 'unit_type',
                value:this.unit_type,
                id: 'unit_type',
                fieldLabel: '对象单位',
                colspan:2,
                margin:'10 0 10 0',
                labelSeparator: '',
                triggerAction: 'all',
                allowBlank: false,
                editable: false,
                displayField: 'dataType',
                valueField: 'value',
                store:  Ext.create('js.store.Object.ObjectQueryOneStore'),
            }
            ]

        }
        let basicInformationListB={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            flex:2,
            items:[ {
                xtype: 'textarea',
                name: 'check_details',
                id: 'check_details',
                allowBlank: false,
                msgTarget : 'qtip',
                value:this.check_details,
                margin:'10 0 10 0',
                width: '100%',
                height:'100',
                labelSeparator: '',
                fieldLabel: '抽查详情记录:',
            }
            ]

        }
        let basicInformationListC={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[{
                xtype: 'radiogroup',
                fieldLabel: '是否下发整改',
                margin:'10 0 10 0',
                id: 'check_result',
                name: 'check_result',
                value: this.check_num ? this.check_num : '1',
                vertical: true,
                items: [
                    {boxLabel: '是', inputValue: '1', margin: '2 0 0 0', id: 'sfxxxgAA'},
                    {boxLabel: '否', inputValue: '2', margin: '2 0 0 20', id: 'sfxxxgBB'}
                ],
                listeners :{
                    change:function(group,checked){
                        if(checked.check_result == 2){
                            Ext.getCmp('rectification_date').setDisabled(true);
                            Ext.getCmp('rectification_reply').setDisabled(true);
                            Ext.getCmp('remarks').setDisabled(true);
                            Ext.getCmp('rectification_notice').setDisabled(true);
                            Ext.getCmp('rectification_date').setValue('');
                            Ext.getCmp('rectification_reply').setValue('');
                            Ext.getCmp('remarks').setValue('');
                            Ext.getCmp('rectification_notice').setValue('');
                        }else{
                            Ext.getCmp('rectification_date').setDisabled(false);
                            Ext.getCmp('rectification_reply').setDisabled(false);
                            Ext.getCmp('remarks').setDisabled(false);
                            Ext.getCmp('rectification_notice').setDisabled(false);
                        }
                    },
                    render:function (value) {
                        var bizVal = value.initialConfig.value;
                        if(bizVal == 2){
                            //禁用rectification_reply remarks rectification_notice
                            /*  /!*Ext.getCmp('rectification_reply ').setDisabled(true);
                              Ext.getCmp('remarks').setDisabled(true);
                              Ext.getCmp('rectification_notice').setDisabled(true);*!/*/
                            Ext.getCmp('sfxxxgBB').setValue(true);
                        }else{
                            Ext.getCmp('sfxxxgAA').setValue(true);
                        }
                    }
                }
            }
            ]

        }
        let basicInformationListD={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items:[ {
                xtype: 'textfield',
                name: 'rectification_notice',
                id: 'rectification_notice',
                msgTarget : 'qtip',
                value:this.rectification_notice,
                margin:'10 0 10 0',
                width: '50%',
                labelSeparator: '',
                fieldLabel: '整改通知单:'
            },{
                xtype: 'datefield',
                editable:false,
                name: 'rectification_date',
                id: 'rectification_date',
                value:this.rectification_date,
                msgTarget : 'qtip',
                width: '50%',
                margin:'10 0 10 0',
                labelSeparator: '',
                labelWidth:130,
                fieldLabel: '<span style="margin-left:30px; ">整改完成日期:</span>'
            }
            ]

        };
        let zghf={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            flex:2,
            items:[   {
                xtype: 'textarea',
                name: 'rectification_reply',
                id: 'rectification_reply',
                margin:'10 0 10 0',
                msgTarget : 'qtip',
                value:this.rectification_reply,
                width: '100%',
                labelSeparator: '',
                fieldLabel: '整改回复:',
            }
            ]

        };

        let basicInformationListE={
            xtype:'panel',
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            flex:2,
            items:[   {
                xtype: 'textarea',
                name: 'remarks',
                id: 'remarks',
                margin:'10 0 10 0',
                msgTarget : 'qtip',
                value:this.remarks,
                width: '100%',
                labelSeparator: '',
                fieldLabel: '备注:',
            }
            ]

        };
        this.items = [basicInformationList,basicInformationListB,basicInformationListC,basicInformationListD,zghf,basicInformationListE];

        this.callParent(arguments);
    },
    submit: function () {
        let form = this.getForm();
        let params = Ext.Object.merge({action_type: this.action_type,engineering_id:  this.engineering_id,}, this.hidenField);
        if (form.isValid()) {
            form.submit({
                params: params,
                success: this.success,
                failure: this.fail
            });
        }
    },
    success: function (response) {
        Ext.toast('保存成功');
    },
    fail: function (form, action) {
        Ext.toast(`<div style="font-size:28px;">保存失败，${action.failureType}，${action.result.message}</div>`);
    },
    afterrender: function (t, eop) {
        t.items.get(0).setValue(true);
    }
});